<script type="text/javascript">
$(function(){
	new $.Agrid('#books-grid');
});
</script>
<div id="books-grid" class="agrid">
	<a class="edit new" href="editbook.php">Add a book</a>
	<table>
	<thead><tr>
		<th data-format="{id}">
			<a class="sortable" 
				href="" 
				sort-asc="books.php?sort=id&amp;dir=asc" 
				sort-desc="books.php?sort=id&amp;dir=desc" 
				<?php if ($this->sort == 'id') echo 'sort-dir="' . $this->sort_dir . '"'; ?>>#</a></th>
		<th data-format="&lt;a href=&quot;editbook.php?id={id}&quot; class=&quot;edit&quot;&gt;{title}&lt;/a&gt;">
			<a class="sortable" 
				href="" 
				sort-asc="books.php?sort=title&amp;dir=asc" 
				sort-desc="books.php?sort=title&amp;dir=desc"
				<?php if ($this->sort == 'title') echo 'sort-dir="' . $this->sort_dir . '"'; ?>>Title</a></th>
		<th data-format="&lt;a href=&quot;deletebook.php?id={id}&quot; class=&quot;delete&quot; title=&quot;Delete {title}&quot;&gt;Delete&lt;/a&gt;"><a>Actions</a></th>
	</tr></thead>
	<tbody>
	<?php foreach ($this->books as $book) :?>
		<?php $title = $this->escape($book['title']); ?>
		<tr>
			<td><?php echo $book['id']; ?></td>
			<td><a href="editbook.php?id=<?php echo $book['id']; ?>" 
				class="edit" 
				title="Edit <?php echo $title; ?>"><?php echo $title; ?></a></td>
			<td><a href="deletebook.php?id=<?php echo $book['id']; ?>" 
				class="delete" 
				title="Delete <?php echo $title; ?>">Delete</a></td>
		</tr>
	<?php endforeach; ?>
	</tbody>
	</table>
</div>